<template>
        <el-card shadow="never" style="max-height: 70vh; overflow: auto">
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
                <el-form-item label="id:" prop="id" v-show="false">
                    <el-input v-model="form.id" disabled />
                </el-form-item>
                <el-form-item label="消费用户:" prop="user_id">
                    <SelectPage v-model="form.user_id" :url="'/admin/user/selectPage'" placeholder="请选择消费用户"
                                show_field="nickname" show_id="uid" query_field="uid" :multiple="false" />
                </el-form-item>
                <el-form-item label="所属面板:" prop="panel_id">
                    <SelectPage v-model="form.panel_id" :url="'/admin/live.panel/selectPage'" placeholder="请选择所属面板"
                                show_field="title" show_id="id" query_field="id" :multiple="false" />
                </el-form-item>
                <el-form-item label="消费金额:" prop="price">
                    <el-input-number v-model="form.price" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="到账咪婴豆:" prop="coin">
                    <el-input-number v-model="form.coin" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="状态:" prop="status">
                    <el-select v-model="form.status" placeholder="请选择状态" clearable>
                        <el-option v-for="(item, index) in status" :key="index" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="支付时间:" prop="pay_time">
                    <el-date-picker v-model="form.pay_time" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择支付时间" />
                </el-form-item>


                <el-form-item>
                    <el-button type="primary" @click="submitForm">确认 </el-button>
                    <el-button type="warning" @click="cancel">取消 </el-button>
                </el-form-item>
            </el-form>
        </el-card>
</template>

<script>
import { regionData } from 'element-china-area-data'
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {}
        },
        editFormParams: {
            type: Object,
            default: {}
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {

            },
            form: {  },
            // 区域选择配置
            areaOptions: regionData,
            status:[
               { label: "待支付", value: 1 },
               { label: "已支付", value: 2 },
               { label: "已取消", value: 3 },
            ],

        }
    },
    watch: {
        findFormData: {
           handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                    })
                }
            },
            immediate: true,
            deep: false,
        },
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        }
    }
}
</script>
